import { StockService } from '../stock.service';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';

@Component({
  selector: 'app-search-form',
  templateUrl: './search-form.component.html',
  styleUrls: ['./search-form.component.css']
})
export class SearchFormComponent implements OnInit {

  public formModule: FormGroup;

  constructor(private router: Router, public fb: FormBuilder,public stockService:StockService) {
  }

  ngOnInit() {
    this.formModule = this.fb.group({
      name: ['123', Validators.required]
    });
  }


  search() {
    if(this.formModule.valid){
      this.stockService.searchEvent.emit(this.formModule.value)
    }
  }

  creat() {
    this.router.navigateByUrl('/stock/0');
  }

}
